package com.example.schooljava.service.impl;

import com.example.schooljava.pojo.entity.Role;
import com.example.schooljava.mapper.RoleMapper;
import com.example.schooljava.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.schooljava.util.Result;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LDH
 * @since 2022/08/11
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Override
    public Result addRole(Role role) {
        save(role);
        return new Result<>().OK(true,"身份添加成功");
    }

    @Override
    public Result delRole(ArrayList<String> list) {
        for (String l : list) {
            for (Role role : list()) {
                if (Long.parseLong(l) == role.getId())
                    removeById(Long.parseLong(l));
            }
        }
        return new Result<>().OK(true,"身份删除成功");
    }
}
